﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Net.WebSockets;
using System.Web.WebSockets;
using Microsoft.Web.WebSockets;

namespace WebSockets2
{
    public class TestWebSocketHandler2 : WebSocketHandler
    {
        //private static WebSocketCollection clients =
        //    new WebSocketCollection();

        private string name;

        //static private TestWebSocketHandler2 theOne;

        public override void OnOpen()
        {
            /*
            if (clients.Count == 1)
            {
                clients.Broadcast("في حدا مصرمج بحاول يفوت معك .. اذا بتشوفه قله يقلب وجهه");
                return;
            }
            theOne = this;
            */
            this.name = this.WebSocketContext.QueryString["visitor"];
            //this.Send("hello");
            //clients.Add(this);
        }

        public override void OnMessage(string message)
        {
            //if (this == theOne)
                //clients.Broadcast(message);
            this.Send(message);
        }

        public override void OnClose()
        {
            
        }
    }
}